package com.TinyBBS.servlet.control;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.TinyBBS.bean.Game;
import com.TinyBBS.model.GameModel;

/**
 * Servlet implementation class GameControl
 */
public class GameControl extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession(true);
		String uri = "Login";
		if(session.getAttribute("username") != null){
			GameModel gameM = new GameModel();
			List<Game> games = gameM.getAllGame();
			session.setAttribute("gameList", games);
			uri = "views/gameControl.jsp";
		}
		RequestDispatcher rd = request.getRequestDispatcher(uri);
		rd.forward(request, response);
	}


}
